var datatable;
/**
 * 加载版本列表
 * @param e
 * @param func  回调函数
 */
function loadRelease(e,func) {
	var env = parseInt($(e).find("option:selected").val());
	$.ajax({
		url : "/smarttest-frontstage/autog7Report/getReleases.action",
		data : { env : env },
		method : 'POST',
		success : function(data) {
				$("#release_usefor").html(data.data);
				if (func) {
					func();
				}
		}
		});
}
//datatable 的类型;1:只选测试环境；2：选择版本和单接口；3：不选版本选择单接口或者选择了测试结果；4：其他
var datatabletype = 0;
/**
 * 查询后数据表的展示
 */
function searchSubmit(){
	   var env = $("#index_usefor").find("option:selected").text();
	   var release = parseInt($("#release_usefor").val());
	   var modules = JSON.stringify($("#module_usefor").val());
	   var idstr = JSON.stringify($("#inf_usefor").val());
	   var idsarr = idstr.split(",");
       var importantsStr = JSON.stringify($("#importants_search").val());
       var ownersStr = JSON.stringify($("#owner_search").val());
       var levels = JSON.stringify($("#level_search").val());
       var results = JSON.stringify($("#result_search").val());
       var time = JSON.stringify($("#reservationT").val());
       if (release!=0 && idstr != "null" && idsarr.length == 1) {
    	   $("#levelsection").show();
       }
       else {
    	   $("#levelsection").find(".bs-deselect-all").eq(0).click();
    	   $("#levelsection").hide();
       }
       //datatabletype == 1
	   if (release == 0 && modules == "null" && idstr == "null" && importantsStr == "null" && ownersStr == "null" && levels == "null" && results == "null"
			   ) {
		   if (datatabletype == 1) {
			   //如果期望datatabletype和上次一致，那么直接刷新。不删除后重新创建
			   datatable.ajax.reload();
		   }
		   else {
			   if (datatable != undefined) {
				   //删除后重新创建
				   datatable.destroy();
			   }
			   var ths = $("#dt_basic > thead > tr");
			   $("#dt_basic > tbody").empty();
			   ths.html("<th style=\"width: 30%;text-align: center;\">迭代版本</th>"+
						"<th style=\"width: 10%;text-align: center;\">pass</th>"+
						"<th style=\"width: 10%;text-align: center;\">fail</th>"+
						"<th style=\"width: 10%;text-align: center;\">skip</th>"+
						"<th style=\"width: 20%;text-align: center;\">执行时间</th>"+
						"<th style=\"width: 10%;text-align: center;\">耗时(ms)</th>"+
						"<th style=\"width: 10%;text-align: center;\">查看详情</th>");
			   datatable = convertDataTable_showreleases();
			   datatabletype = 1; 			   
		   }
		   setTimeout(function(){
			   var datas = datatable.ajax.json().data;
			   var releasearr = new Array();
			   var passarr = new Array();
			   var failarr = new Array();
			   var skiparr = new Array();
			   var usetimearr = new Array();
			   var passpercentarr = new Array();
			   var passnum = 0,failnum = 0,skipnum = 0;
			   for (var i = 0;i < datas.length; i++) {
				   releasearr[i] = datas[i]['name'];
				   passarr[i] = datas[i]['pass'];
				   failarr[i] = datas[i]['fail'];
				   skiparr[i] = datas[i]['skip'];
				   usetimearr[i] = datas[i]['usetimesec'];
				   passpercentarr[i] = parseInt(datas[i]['pass'])/(parseInt(passarr[i])+parseInt(failarr[i])+parseInt(skiparr[i])) * 100;
				   passnum+=parseInt(datas[i]['pass']);
				   failnum+=parseInt(datas[i]['fail']);
				   skipnum+=parseInt(datas[i]['skip']);
			   }
			   setTimeout(function(){
				   var piechartsdata = [["PASS",passnum],["FAILURE",failnum],["SKIP",skipnum]];
				   generateCharts(env,"20170725","20170726",releasearr,passarr,failarr,skiparr,usetimearr,passpercentarr,piechartsdata); 
			   },1);
		   },500);		  
	   }
	 //datatabletype == 3
	   else if (results != "null" || (release==0 && idstr != "null" && idsarr.length == 1)){
		   if (datatabletype == 3) {
			   datatable.ajax.reload();
		   }
		   else {
			   if (datatable != undefined) {
				   datatable.destroy();
			   }
			   var ths = $("#dt_basic > thead > tr");
			   $("#dt_basic > tbody").empty();
			   ths.html("<th style=\"width: 30%;text-align: center;\">接口名</th>"+
						"<th style=\"width: 10%;text-align: center;\">环境</th>"+
						"<th style=\"width: 10%;text-align: center;\">模块</th>"+
						"<th style=\"width: 10%;text-align: center;\">负责人</th>"+
						"<th style=\"width: 10%;text-align: center;\">重要程度</th>"+
						"<th style=\"width: 10%;text-align: center;\">版本</th>"+
						"<th style=\"width: 5%;text-align: center;\">执行结果</th>"+
						"<th style=\"width: 5%;text-align: center;\">执行时间</th>"+
						"<th style=\"width: 5%;text-align: center;\">耗时</th>"+
						"<th style=\"width: 5%;text-align: center;\">查看详情</th>");
			   datatable = convertDataTable_showInterresults();  
			   datatabletype = 3;
		   }
		   setTimeout(function(){
			   var datas = datatable.ajax.json().data;
			   var passarr = new Array();
			   var failarr = new Array();
			   var skiparr = new Array();
			   var passnum = 0,failnum = 0,skipnum = 0;
			   for (var i = 0;i < datas.length; i++) {
				   var result = datas[i]['result']
				   if (result == 'FAIL') {
    				   failnum++;
             	   }
             	   else if (result == 'PASS'){
    				   passnum++;
             	   }
             	  else if (result == 'SKIP'){
    				   skipnum++;
            	   }
			   }
			   setTimeout(function(){
				   
				   passarr[0] = passnum;
				   failarr[0] = failnum;
				   skiparr[0] = skipnum;
				   var piechartsdata = [["PASS",passnum],["FAILURE",failnum],["SKIP",skipnum]];
				   generateCharts_showInterresults(env,passarr,failarr,skiparr,piechartsdata);
			   },1);
		   },100);
		  
	   }
	 //datatabletype == 2
	   else if (release!=0 && idstr != "null" && idsarr.length == 1) {
		   if (datatabletype == 2) {
			   datatable.ajax.reload();
		   }
		   else {
			   if (datatable != undefined) {
				   datatable.destroy();
			   }
			   var ths = $("#dt_basic > thead > tr");
			   $("#dt_basic > tbody").empty();
			   ths.html("<th style=\"width: 15%;text-align: center;\">接口入参</th>"+
						"<th style=\"width: 5%;text-align: center;\">预期code</th>"+
						"<th style=\"width: 10%;text-align: center;\">预期msg</th>"+
						"<th style=\"width: 15%;text-align: center;\">结果断言</th>"+
						"<th style=\"width: 5%;text-align: center;\">期望条数</th>"+
						"<th style=\"width: 5%;text-align: center;\">level</th>"+
						"<th style=\"width: 10%;text-align: center;\">描述</th>"+
						"<th style=\"width: 5%;text-align: center;\">执行结果</th>"+
						"<th style=\"width: 10%;text-align: center;\">执行时间</th>"+
						"<th style=\"width: 5%;text-align: center;\">耗时</th>"+
						"<th style=\"width: 15%;text-align: center;\">异常</th>");
			   datatable = convertDataTable_showScenes();
			   datatabletype = 2;
		   }	
		   setTimeout(function(){
			   var datas = datatable.ajax.json().data;
			   var passarr = new Array();
			   var failarr = new Array();
			   var skiparr = new Array();
			   var passnum = 0,failnum = 0,skipnum = 0;
			   for (var i = 0;i < datas.length; i++) {
				   passarr[i] = datas[i]['pass'];
				   failarr[i] = datas[i]['fail'];
				   skiparr[i] = datas[i]['skip'];
				   passnum+=parseInt(datas[i]['pass']);
				   failnum+=parseInt(datas[i]['fail']);
				   skipnum+=parseInt(datas[i]['skip']);
			   }			   
			   setTimeout(function(){
				   var piechartsdata = [["PASS",passnum],["FAILURE",failnum],["SKIP",skipnum]];
				   passarr[0] = passnum;
				   failarr[0] = failnum;
				   skiparr[0] = skipnum;
				   generateCharts_showScenes(env,release,passarr,failarr,skiparr,piechartsdata);
			   },1);
		   },100);
		   
	   }	 
	 //datatabletype == 4
	   else {
		   if (datatabletype == 4) {
			   datatable.ajax.reload();
		   }
		   else {
			   if (datatable != undefined) {
				   datatable.destroy();
			   }
			   var ths = $("#dt_basic > thead > tr");
			   $("#dt_basic > tbody").empty();
			   ths.html("<th style=\"width: 30%;text-align: center;\">接口名</th>"+
						"<th style=\"width: 10%;text-align: center;\">环境</th>"+
						"<th style=\"width: 10%;text-align: center;\">模块</th>"+
						"<th style=\"width: 20%;text-align: center;\">负责人</th>"+
						"<th style=\"width: 10%;text-align: center;\">重要程度</th>"+
						"<th style=\"width: 5%;text-align: center;\">pass</th>"+
						"<th style=\"width: 5%;text-align: center;\">fail</th>"+
						"<th style=\"width: 5%;text-align: center;\">skip</th>"+
						"<th style=\"width: 5%;text-align: center;\">查看详情</th>");
			   datatable = convertDataTable_showInters(); 
			   datatabletype = 4; 
		   }	
		   setTimeout(function(){
			   var datas = datatable.ajax.json().data;
			   var passarr = new Array();
			   var failarr = new Array();
			   var skiparr = new Array();
			   var internamearr = new Array();
			   var passnum = 0,failnum = 0,skipnum = 0;
			   for (var i = 0;i < datas.length; i++) {
				   internamearr[i] = datas[i]['name'];
				   passarr[i] = datas[i]['pass'];
				   failarr[i] = datas[i]['fail'];
				   skiparr[i] = datas[i]['skip'];
				   passnum+=parseInt(datas[i]['pass']);
				   failnum+=parseInt(datas[i]['fail']);
				   skipnum+=parseInt(datas[i]['skip']);
			   }
			   setTimeout(function(){
				   var piechartsdata = [["PASS",passnum],["FAILURE",failnum],["SKIP",skipnum]];
				   generateCharts_showInters(env,internamearr,passarr,failarr,skiparr,piechartsdata);
			   },1);
		   },100);
		   
	   }  
}
//更改图表类型(柱状图、切面图、曲线图等)
function ChangeChartType(chart, series, newType) {
    newType = newType.toLowerCase();
    for (var i = 0; i < series.length; i++) {
        var srs = series[0];
        try {
            srs.chart.addSeries({
                type: newType,
                stack: srs.stack,
                yAxis: srs.options.yAxis,
                name: srs.name,
                color: srs.color,
                data: srs.options.data
            },
            false);
            series[0].remove();
        } catch (e) {
        }
    }
}
//Two charts definition
var chart1, chart2;
/**
 * 生成图表-展示接口场景 datatype=2
 * @param env
 * @param release
 * @param pass
 * @param fail
 * @param skip
 * @param piechartsdata
 */
function generateCharts_showScenes(env,release,pass,fail,skip,piechartsdata) {
	var title1 = env+"--"+release+':执行结果';
	var yAxis1 = [
	          	{ //  Primary yAxis
	        	    title: {
	        	        text: '成功/失败条数',
//	        	        style: {
//	        	            color: '#AA4643'
//	        	        }
	        	    },
	        	    labels: {
//	        	        style: {
//	        	            color: '#AA4643'
//	        	        }
	        	    },
//	        	    allowDecimals:false,
	        	}  ,
	   
	          ];
	var series1 = [
	       		{ 
	      		  name: 'pass',
	      		  data:pass
	      		}, {
	      		  name: 'fail',
	      		  data:fail
	      		}, {
	      		  name: 'skip',
	      		  data:skip
	      		},];
	var title2 = '<p>'+env+'</p><p>统计饼状图<p>';
	var series2 = [{
	      type: 'pie',
	         name: 'piecharts',
	         data:piechartsdata
	      }];
	var categories = [env+"--"+release];
	generateCharts_common(title1,categories,yAxis1,series1,title2,series2);
}

/**
 * 生成图表-展示接口 datatype=4
 * @param env
 * @param intername
 * @param pass
 * @param fail
 * @param skip
 * @param piechartsdata
 */
function generateCharts_showInters(env,intername,pass,fail,skip,piechartsdata) {
	var title1 = env+':接口执行结果汇总';
	var yAxis1 = [
	          	{ //  Primary yAxis
	        	    title: {
	        	        text: '成功/失败条数',
//	        	        style: {
//	        	            color: '#AA4643'
//	        	        }
	        	    },
	        	    labels: {
//	        	        style: {
//	        	            color: '#AA4643'
//	        	        }
	        	    },
//	        	    allowDecimals:false,
	        	}  ,
	        	
	          ];
	var series1 = [
	       		{ 
	      		  name: 'pass',
	      		  data:pass
	      		}, {
	      		  name: 'fail',
	      		  data:fail
	      		}, {
	      		  name: 'skip',
	      		  data:skip
	      		},];
	var title2 = '<p>'+env+'</p><p>统计饼状图<p>';
	var series2 = [{
	      type: 'pie',
	         name: 'piecharts',
	         data:piechartsdata
	      }];
	var categories = intername;
	generateCharts_common(title1,categories,yAxis1,series1,title2,series2);
}
/**
 * 生成图表-展示接口执行结果汇总 datatype=3
 * @param env
 * @param pass
 * @param fail
 * @param skip
 * @param piechartsdata
 */
function generateCharts_showInterresults(env,pass,fail,skip,piechartsdata) {
	var title1 = env+':接口执行结果汇总';
	var yAxis1 = [
	          	{ //  Primary yAxis
	        	    title: {
	        	        text: '成功/失败条数',
//	        	        style: {
//	        	            color: '#AA4643'
//	        	        }
	        	    },
	        	    labels: {
//	        	        style: {
//	        	            color: '#AA4643'
//	        	        }
	        	    },
//	        	    allowDecimals:false,
	        	}  ,
	          ];
	var series1 = [
	       		{ 
	      		  name: 'pass',
	      		  data:pass
	      		}, {
	      		  name: 'fail',
	      		  data:fail
	      		}, {
	      		  name: 'skip',
	      		  data:skip
	      		},];
	var title2 = '<p>'+env+'</p><p>统计饼状图<p>';
	var series2 = [{
	      type: 'pie',
	         name: 'piecharts',
	         data:piechartsdata
	      }];
	var categories = [''];
	generateCharts_common(title1,categories,yAxis1,series1,title2,series2);
}
/**
 * 展示图表的公共调用
 * @param title1
 * @param categories
 * @param yAxis1
 * @param series1
 * @param title2
 * @param series2
 */
function generateCharts_common(title1,categories,yAxis1,series1,title2,series2) {
	//根据width1，width2设置两个图表随分辨率自动化变化。但相对于屏幕的位置不变
	var width1 = $("#case_map").get(0).offsetWidth*0.8;
	var width2 = $("#case_map").get(0).offsetWidth*0.18;
	//第一张图表
 chart1 = new Highcharts.Chart({
  chart: {
     renderTo: 'chart_1',
     type: 'column',
     height: 350,
     width:width1
  },
  title: {
     text: title1
  },
  //x轴
  xAxis: {
	  categories : categories
  },
  //y轴
  yAxis:yAxis1,
  scrollbar: {
      enabled: true
  },
  //图表导航标签
 series: series1
 });
 //第二张表：饼状图
 chart2 = new Highcharts.Chart({
     chart: {
         renderTo: 'chart_2',
         plotBackgroundColor: null,
         plotBorderWidth: null,
         plotShadow: false,
         height: 350,
         width:width2
     },
     title: {
         text: title2,
         useHTML:true,
     },
     tooltip: {
         pointFormat: '<b>{point.percentage}%</b>',
         percentageDecimals: 1
     },
     plotOptions: {
         pie: {
             allowPointSelect: true,
             cursor: 'pointer',
             dataLabels: {
                 enabled: false
             },
             showInLegend: true
         }
     },
      series: series2
 });
 $('.switcher').click(function () {  
     var newType = $(this).attr('id');
     ChangeChartType(chart1, chart1.series, newType);
 });
}
/**
 * 展示图表:datatype=1
 * @param env
 * @param from
 * @param to
 * @param categories
 * @param pass
 * @param fail
 * @param skip
 * @param totaltimes
 * @param passpercent
 * @param piechartsdata
 */
//Once DOM (document) is finished loading
function generateCharts(env,from,to,categories,pass,fail,skip,totaltimes,passpercent,piechartsdata) {
	var width1 = $("#case_map").get(0).offsetWidth*0.8;
	var width2 = $("#case_map").get(0).offsetWidth*0.18;
 // First chart initialization
 chart1 = new Highcharts.Chart({
  chart: {
     renderTo: 'chart_1',
     type: 'column',
     height: 350,
     width:width1
  },
  title: {
     text: env+':迭代版本统计图(只显示最近的14条)'
  },
  xAxis: {
	  categories : categories
  },
  scrollbar: {
      enabled: true
  },
  yAxis:[
	{ //  Primary yAxis
	    title: {
	        text: '成功/失败条数',
//	        style: {
//	            color: '#AA4643'
//	        }
	    },
	    labels: {
//	        style: {
//	            color: '#AA4643'
//	        }
	    },
	    allowDecimals:false,
	}  ,
	{ // Secondary yAxis
	    title: {
	        text: '耗时',
	        style: {
	            color: '#7798BF'
	        }
	    },
	    labels: {
	        formatter: function() {
	            return this.value +' ms';
	        },
	        style: {
	            color: '#7798BF'
	        }
	    },
	    opposite: true
	} ,
	{ // Tertiary yAxis
		gridLineWidth: 0,
	    labels: {
	        formatter: function() {
	            return this.value +'%';
	        },
	        style: {
	            color: '#89A54E'
	        }
	    },
	    title: {
	        text: '成功率',
	        style: {
	            color: '#89A54E'
	        }
	    },
	    opposite: true,
	    tickPositions: [0, 20, 40, 60, 80, 100]
	}
  ],  
  //图表导航标签
 series: [
		{ 
		  name: 'pass',
		  data:pass,
		  yAxis: 0,
		}, {
		  name: 'fail',
		  data:fail,
		  yAxis: 0,
		}, {
		  name: 'skip',
		  data:skip,
		  yAxis: 0,
		},{
		   name: '耗时(ms)',
		   data:totaltimes,
	        yAxis: 1,
	        tooltip: {
	            valueSuffix: ' ms'
	        }
		}
    ,
 {
 	yAxis: 2,
     name: '成功率',
     color: '#89A54E',
     type: 'spline',
//     data: [87,88,50,40,20,90,100,20,0,50,39,78,80,90],
     data:passpercent,
     tooltip: {
         valueSuffix: ' %'
     }
 }]
 });
 // Second chart initialization (pie chart)
 chart2 = new Highcharts.Chart({
     chart: {
         renderTo: 'chart_2',
         plotBackgroundColor: null,
         plotBorderWidth: null,
         plotShadow: false,
         height: 350,
         width:width2
     },
     title: {
         text: '<p>'+env+'</p><p>迭代版本统计饼状图<p>',
         useHTML:true,
     },
     tooltip: {
         pointFormat: '<b>{point.percentage}%</b>',
         percentageDecimals: 1
     },
     plotOptions: {
         pie: {
             allowPointSelect: true,
             cursor: 'pointer',
             dataLabels: {
                 enabled: false
             },
             showInLegend: true
         }
     },
      series: [{
      type: 'pie',
         name: 'piecharts',
         /*data: [
             ['PASS', 5],
             ['FAILURE', 10],
             ['SKIP', 20],
             ['Ease.js', 22],
             ['Box2D.js', 25],
             ['WebGL', 28],
             ['DOM', 30],
             ['CSS', 40],
             ['Canvas', 80],
             ['Javascript', 90]
         ]*/
         data:piechartsdata
      }]
 });

 // Switchers (of the Chart1 type) - onclick handler
 $('.switcher').click(function () {  
     var newType = $(this).attr('id');
     ChangeChartType(chart1, chart1.series, newType);
 });
}
/**
 * 生成datatable:datatype=1
 * @returns
 */
function convertDataTable_showreleases () {
	var ajax = {
        "url": "/smarttest-frontstage/autog7Report/getReports.action",
        "type": "POST",
        "data": function(){
     	   return {
     		   "env" : parseInt($("#index_usefor").val()),
     		   "release" : parseInt($("#release_usefor").val()),
     		   "modules" : JSON.stringify($("#module_usefor").val()),
     		   "idStr" : JSON.stringify($("#inf_usefor").val()),
   		     "importantsStr" : JSON.stringify($("#importants_search").val()),
   		     "ownersStr" : JSON.stringify($("#owner_search").val()),
   		   "levels" : JSON.stringify($("#level_search").val()),
   		   "results" : JSON.stringify($("#result_search").val()),
   		   "time" : JSON.stringify($("#reservationT").val()),
     	    }
        }
	};
	var aoColumnDefs = [
    {
        targets: 1,
        data: "pass",
        render: function (data, type, row, meta) {
            return '<font color="green">'+data+'</font>';
        }
    },
    {
        targets: 2,
        data: "fail",
        render: function (data, type, row, meta) {
        	return '<font color="red">'+data+'</font>';
        }
    },
    {
        targets: 3,
        data: "skip",
        render: function (data, type, row, meta) {
        	return '<font color="yellow">'+data+'</font>';
        }
    },
    {
        targets: 4,
        data: "exctime",
        render: function (data, type, row, meta) {
     	   var exctime = data==null?"":new Date(parseInt(data)).Format("yyyy-MM-dd hh:mm:ss");
            return exctime;
        }
    },
   
    {
        targets: 6,
        data: "releaseid",
        render: function (data, type, row, meta) {
            return '<a class="btn btn-primary btn-sm" langlanguage="query" type="button" onclick="">查看详情</a>';
        }
    },
		];
	var columns = [
	               { "data": "name" },
	   				{ "data": "pass" },
	              { "data": "fail" },
	              { "data": "skip" },
	              { "data": "exctime" },
	              { "data": "usetimesec" },
	              { "data": "releaseid" }
	          ];
	var initCompletefunc = "";
    return convertDataTable_common($('#dt_basic'),ajax,aoColumnDefs,columns,initCompletefunc,true);
}
/**
 * 生成datatable:datatype=2
 * @returns
 */
function convertDataTable_showScenes () {
	var ajax = {
        "url": "/smarttest-frontstage/autog7Report/getReports.action",
        "type": "POST",
        "data": function(){
     	   return {
     		   "env" : parseInt($("#index_usefor").val()),
     		   "release" : parseInt($("#release_usefor").val()),
     		   "modules" : JSON.stringify($("#module_usefor").val()),
     		   "idStr" : JSON.stringify($("#inf_usefor").val()),
   		     "importantsStr" : JSON.stringify($("#importants_search").val()),
   		     "ownersStr" : JSON.stringify($("#owner_search").val()),
   		   "levels" : JSON.stringify($("#level_search").val()),
   		   "results" : JSON.stringify($("#result_search").val()),
   		   "time" : JSON.stringify($("#reservationT").val()),
     	    }
        }
	};
	var aoColumnDefs = [
    {
    	targets: 7,
        data: "result",
        render: function (data, type, row, meta) {
     	   var result;
     	   if (data == 1) {
     		   result = '<font color="red">FAIL</font>';
     	   }
     	   else if (data == 0){
     		   result = '<font color="green">PASS</font>'; 
     	   }
     	  else if (data == 2){
    		   result = '<font color="yellow">SKIP</font>'; 
    	   }
     	   else {
     		   result = ""; 
     	   }
            return result;
        }
    },
    {
        targets: 8,
        data: "exctime",
        render: function (data, type, row, meta) {
     	   var exctime = data==null?"":new Date(parseInt(data)).Format("yyyy-MM-dd hh:mm:ss");
            return exctime;
        }
    },
		];
	var columns = [
	               { "data": "innerparams" },
	   				{ "data": "expectcode" },
	              { "data": "expectmsg" },
	              { "data": "resultasserts" },
	              { "data": "expectcount" },
	              { "data": "level" },
	              { "data": "description" },
	              { "data": "result" },
	              { "data": "exctime" },
	              { "data": "usetimemsec" },
	              { "data": "exception" }
	          ];
	var initCompletefunc = "";
    return convertDataTable_common($('#dt_basic'),ajax,aoColumnDefs,columns,initCompletefunc,true);
}
/**
 * 生成datatable:datatype=4
 * @returns
 */
function convertDataTable_showInters () {
	var ajax = {
	        "url": "/smarttest-frontstage/autog7Report/getReports.action",
	        "type": "POST",
	        "data": function(){
	     	   return {
	     		   "env" : parseInt($("#index_usefor").val()),
	     		   "release" : parseInt($("#release_usefor").val()),
	     		   "modules" : JSON.stringify($("#module_usefor").val()),
	     		   "idStr" : JSON.stringify($("#inf_usefor").val()),
	   		     "importantsStr" : JSON.stringify($("#importants_search").val()),
	   		     "ownersStr" : JSON.stringify($("#owner_search").val()),
	   		   "levels" : JSON.stringify($("#level_search").val()),
	   		   "results" : JSON.stringify($("#result_search").val()),
	   		   "time" : JSON.stringify($("#reservationT").val()),
	     	    }
	        }
		};
		var aoColumnDefs = [
			{
			    targets: 5,
			    data: "pass",
			    render: function (data, type, row, meta) {
			        return '<font color="green">'+data+'</font>';
			    }
			},
			{
			    targets: 6,
			    data: "fail",
			    render: function (data, type, row, meta) {
			    	return '<font color="red">'+data+'</font>';
			    }
			},
			{
			    targets: 7,
			    data: "skip",
			    render: function (data, type, row, meta) {
			    	return '<font color="yellow">'+data+'</font>';
			    }
			},
			
			{
			    targets: 8,
			    data: "id",
			    render: function (data, type, row, meta) {
			        return '<a class="btn btn-primary btn-sm" langlanguage="query" type="button" onclick="">查看详情</a>';
			    }
			},
			];
		var columns = [
		               { "data": "name" },
		   				{ "data": "env" },
		              { "data": "module" },
		              { "data": "tester" },
		              { "data": "degree" },
		              { "data": "pass" },
		              { "data": "fail" },
		              { "data": "skip" },
		              { "data": "id" },
		          ];
		var initCompletefunc = "";
		return convertDataTable_common($('#dt_basic'),ajax,aoColumnDefs,columns,initCompletefunc,true);
}
/**
 * 生成datatable:datatype=3
 * @returns
 */
function convertDataTable_showInterresults () {
	var ajax = {
	        "url": "/smarttest-frontstage/autog7Report/getReports.action",
	        "type": "POST",
	        "data": function(){
	     	   return {
	     		   "env" : parseInt($("#index_usefor").val()),
	     		   "release" : parseInt($("#release_usefor").val()),
	     		   "modules" : JSON.stringify($("#module_usefor").val()),
	     		   "idStr" : JSON.stringify($("#inf_usefor").val()),
	   		     "importantsStr" : JSON.stringify($("#importants_search").val()),
	   		     "ownersStr" : JSON.stringify($("#owner_search").val()),
	   		   "levels" : JSON.stringify($("#level_search").val()),
	   		   "results" : JSON.stringify($("#result_search").val()),
	   		   "time" : JSON.stringify($("#reservationT").val()),
	     	    }
	        }
		};
		var aoColumnDefs = [
							{
							    targets: 5,
							    data: "releaseid",
							    render: function (data, type, row, meta) {
							    	if (data == null) {
								    	return "";
							    	}
							    	else {
							    		var relsname = "";
							    		$.ajax({
							    			url : "/smarttest-frontstage/autog7/getReleaseName.action",
							    			data : { releaseid : data },
							    			method : 'POST',
							    			async:false,
							    			success : function(json) {
							    				relsname = json.data;
							    			}
							    		});
							    		return relsname;
							    	}
							    }
							},
		                    {
		                    	targets: 6,
		                        data: "result",
		                        render: function (data, type, row, meta) {
		                     	   var result;
		                     	   if (data == 'FAIL') {
		                     		   result = '<font color="red">FAIL</font>';
		                     	   }
		                     	   else if (data == 'PASS'){
		                     		   result = '<font color="green">PASS</font>'; 
		                     	   }
		                     	  else if (data == 'SKIP'){
		                    		   result = '<font color="yellow">SKIP</font>'; 
		                    	   }
		                     	   else {
		                     		   result = ""; 
		                     	   }
		                            return result;
		                        }
		                    },
		                    {
		                        targets: 7,
		                        data: "exctime",
		                        render: function (data, type, row, meta) {
		                     	   var exctime = data==null?"":new Date(parseInt(data)).Format("yyyy-MM-dd hh:mm:ss");
		                            return exctime;
		                        }
		                    },
		                    {
		                        targets: 9,
		                        data: "id",
		                        render: function (data, type, row, meta) {
		        			        return '<a class="btn btn-primary btn-sm" langlanguage="query" type="button" onclick="">查看详情</a>';
		                        }
		                    },
		                		
			];
		var columns = [
		               { "data": "name" },
		   				{ "data": "env" },
		              { "data": "module" },
		              { "data": "tester" },
		              { "data": "degree" },
		              { "data": "releaseid" },
		              { "data": "result" },
		              { "data": "exctime" },
		              { "data": "usetimemsec" },
		              { "data": "id" }
		          ];
		var initCompletefunc = "";
		return convertDataTable_common($('#dt_basic'),ajax,aoColumnDefs,columns,initCompletefunc,true);
}